phy_col_normal_x

Returns the x component of the collision normal for the associated collision point.

语法:

phy_col_normal_x;


返回: 布尔值


描述

This read-only variable returns the x component of the collision normal corresponding to the phy_collision_x array value. For each contact point there is an associated contact normal (which is usually the same normal for all points of contact in the collision). This contact normal is a unit vector that points from one instance in the collision to another, and can be used, for example, to calculate the correct "push" direction to resolve collisions.

NOTE: This variable is only available in the collision event of a physics enabled instance.


例如:

repeat(5 + irandom(5))
   {
   with (instance_create_layer(x, y, "Effects", obj_Debris)
      {
      physics_apply_local_impulse(0, 0, other.phy_col_normal_x[0], other.phy_col_normal_y[0]);
      }
   }

The above code uses the contact normal to set the direction of movement for an instance created in the collision event between two physics enabled instances.


上一页: Physics Variables
next: phy_col_normal_y
© Copyright YoYo Games Ltd. 2018 All Rights Reserved